package com.itheima.ydd.mapper;

import com.itheima.ydd.entity.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2022-05-22
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {

    @Select("SELECT ydd_cate.id,ydd_cate.`catename`, COUNT(*) AS num FROM ydd_article,ydd_cate WHERE ydd_cate.id=ydd_article.`cateid` GROUP BY ydd_cate.id")
    List<Map<String,Object>> getAllCate();

    @Select("select id,username ,sex,icon,address from ydd_user ORDER BY id desc limit 7 ;")
    List<Map<String,Object>> getNewUser();

    @Select("select id,title,author,keywords,click from ydd_article where ishot=1;")
    List<Map<String,Object>> getHotArticle();

    @Select("select sex, COUNT(*) as total from ydd_user group by sex;")
    List<Map<String,Object>> getUser();
}
